\documentclass[11pt]{article}

    \usepackage[breakable]{tcolorbox}
    \usepackage{parskip} % Stop auto-indenting (to mimic markdown behaviour)
    
    \usepackage{iftex}
    \ifPDFTeX
    	\usepackage[T1]{fontenc}
    	\usepackage{mathpazo}
    \else
    	\usepackage{fontspec}
    \fi

    % Basic figure setup, for now with no caption control since it's done
    % automatically by Pandoc (which extracts ![](path) syntax from Markdown).
    \usepackage{graphicx}
    % Maintain compatibility with old templates. Remove in nbconvert 6.0
    \let\Oldincludegraphics\includegraphics
    % Ensure that by default, figures have no caption (until we provide a
    % proper Figure object with a Caption API and a way to capture that
    % in the conversion process - todo).
    \usepackage{caption}
    \DeclareCaptionFormat{nocaption}{}
    \captionsetup{format=nocaption,aboveskip=0pt,belowskip=0pt}

    \usepackage{float}
    \floatplacement{figure}{H} % forces figures to be placed at the correct location
    \usepackage{xcolor} % Allow colors to be defined
    \usepackage{enumerate} % Needed for markdown enumerations to work
    \usepackage{geometry} % Used to adjust the document margins
    \usepackage{amsmath} % Equations
    \usepackage{amssymb} % Equations
    \usepackage{textcomp} % defines textquotesingle
    % Hack from http://tex.stackexchange.com/a/47451/13684:
    \AtBeginDocument{%
        \def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code
    }
    \usepackage{upquote} % Upright quotes for verbatim code
    \usepackage{eurosym} % defines \euro
    \usepackage[mathletters]{ucs} % Extended unicode (utf-8) support
    \usepackage{fancyvrb} % verbatim replacement that allows latex
    \usepackage{grffile} % extends the file name processing of package graphics 
                         % to support a larger range
    \makeatletter % fix for old versions of grffile with XeLaTeX
    \@ifpackagelater{grffile}{2019/11/01}
    {
      % Do nothing on new versions
    }
    {
      \def\Gread@@xetex#1{%
        \IfFileExists{"\Gin@base".bb}%
        {\Gread@eps{\Gin@base.bb}}%
        {\Gread@@xetex@aux#1}%
      }
    }
    \makeatother
    \usepackage[Export]{adjustbox} % Used to constrain images to a maximum size
    \adjustboxset{max size={0.9\linewidth}{0.9\paperheight}}

    % The hyperref package gives us a pdf with properly built
    % internal navigation ('pdf bookmarks' for the table of contents,
    % internal cross-reference links, web links for URLs, etc.)
    \usepackage{hyperref}
    % The default LaTeX title has an obnoxious amount of whitespace. By default,
    % titling removes some of it. It also provides customization options.
    \usepackage{titling}
    \usepackage{longtable} % longtable support required by pandoc >1.10
    \usepackage{booktabs}  % table support for pandoc > 1.12.2
    \usepackage[inline]{enumitem} % IRkernel/repr support (it uses the enumerate* environment)
    \usepackage[normalem]{ulem} % ulem is needed to support strikethroughs (\sout)
                                % normalem makes italics be italics, not underlines
    \usepackage{mathrsfs}
    

    
    % Colors for the hyperref package
    \definecolor{urlcolor}{rgb}{0,.145,.698}
    \definecolor{linkcolor}{rgb}{.71,0.21,0.01}
    \definecolor{citecolor}{rgb}{.12,.54,.11}

    % ANSI colors
    \definecolor{ansi-black}{HTML}{3E424D}
    \definecolor{ansi-black-intense}{HTML}{282C36}
    \definecolor{ansi-red}{HTML}{E75C58}
    \definecolor{ansi-red-intense}{HTML}{B22B31}
    \definecolor{ansi-green}{HTML}{00A250}
    \definecolor{ansi-green-intense}{HTML}{007427}
    \definecolor{ansi-yellow}{HTML}{DDB62B}
    \definecolor{ansi-yellow-intense}{HTML}{B27D12}
    \definecolor{ansi-blue}{HTML}{208FFB}
    \definecolor{ansi-blue-intense}{HTML}{0065CA}
    \definecolor{ansi-magenta}{HTML}{D160C4}
    \definecolor{ansi-magenta-intense}{HTML}{A03196}
    \definecolor{ansi-cyan}{HTML}{60C6C8}
    \definecolor{ansi-cyan-intense}{HTML}{258F8F}
    \definecolor{ansi-white}{HTML}{C5C1B4}
    \definecolor{ansi-white-intense}{HTML}{A1A6B2}
    \definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF}
    \definecolor{ansi-default-inverse-bg}{HTML}{000000}

    % common color for the border for error outputs.
    \definecolor{outerrorbackground}{HTML}{FFDFDF}

    % commands and environments needed by pandoc snippets
    % extracted from the output of `pandoc -s`
    \providecommand{\tightlist}{%
      \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
    \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
    % Add ',fontsize=\small' for more characters per line
    \newenvironment{Shaded}{}{}
    \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
    \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
    \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
    \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
    \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
    \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
    \newcommand{\RegionMarkerTok}[1]{{#1}}
    \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
    \newcommand{\NormalTok}[1]{{#1}}
    
    % Additional commands for more recent versions of Pandoc
    \newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{{#1}}}
    \newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{{#1}}}
    \newcommand{\ImportTok}[1]{{#1}}
    \newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{{#1}}}}
    \newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{{#1}}}
    \newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
    \newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{{#1}}}
    \newcommand{\BuiltInTok}[1]{{#1}}
    \newcommand{\ExtensionTok}[1]{{#1}}
    \newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{{#1}}}
    \newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}}
    \newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    
    
    % Define a nice break command that doesn't care if a line doesn't already
    % exist.
    \def\br{\hspace*{\fill} \\* }
    % Math Jax compatibility definitions
    \def\gt{>}
    \def\lt{<}
    \let\Oldtex\TeX
    \let\Oldlatex\LaTeX
    \renewcommand{\TeX}{\textrm{\Oldtex}}
    \renewcommand{\LaTeX}{\textrm{\Oldlatex}}
    % Document parameters
    % Document title
    \title{ex\_4\_5}
    
    
    
    
    
% Pygments definitions
\makeatletter
\def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax%
    \let\PY@ul=\relax \let\PY@tc=\relax%
    \let\PY@bc=\relax \let\PY@ff=\relax}
\def\PY@tok#1{\csname PY@tok@#1\endcsname}
\def\PY@toks#1+{\ifx\relax#1\empty\else%
    \PY@tok{#1}\expandafter\PY@toks\fi}
\def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{%
    \PY@it{\PY@bf{\PY@ff{#1}}}}}}}
\def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}}

\@namedef{PY@tok@w}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}}
\@namedef{PY@tok@c}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cp}{\def\PY@tc##1{\textcolor[rgb]{0.74,0.48,0.00}{##1}}}
\@namedef{PY@tok@k}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kt}{\def\PY@tc##1{\textcolor[rgb]{0.69,0.00,0.25}{##1}}}
\@namedef{PY@tok@o}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@ow}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\@namedef{PY@tok@nb}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@nf}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@nc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@nn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@ne}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.82,0.25,0.23}{##1}}}
\@namedef{PY@tok@nv}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@no}{\def\PY@tc##1{\textcolor[rgb]{0.53,0.00,0.00}{##1}}}
\@namedef{PY@tok@nl}{\def\PY@tc##1{\textcolor[rgb]{0.63,0.63,0.00}{##1}}}
\@namedef{PY@tok@ni}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.60,0.60,0.60}{##1}}}
\@namedef{PY@tok@na}{\def\PY@tc##1{\textcolor[rgb]{0.49,0.56,0.16}{##1}}}
\@namedef{PY@tok@nt}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@nd}{\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\@namedef{PY@tok@s}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sd}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@si}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\@namedef{PY@tok@se}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.13}{##1}}}
\@namedef{PY@tok@sr}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\@namedef{PY@tok@ss}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@sx}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@m}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@gh}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\@namedef{PY@tok@gu}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.50,0.00,0.50}{##1}}}
\@namedef{PY@tok@gd}{\def\PY@tc##1{\textcolor[rgb]{0.63,0.00,0.00}{##1}}}
\@namedef{PY@tok@gi}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.63,0.00}{##1}}}
\@namedef{PY@tok@gr}{\def\PY@tc##1{\textcolor[rgb]{1.00,0.00,0.00}{##1}}}
\@namedef{PY@tok@ge}{\let\PY@it=\textit}
\@namedef{PY@tok@gs}{\let\PY@bf=\textbf}
\@namedef{PY@tok@gp}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\@namedef{PY@tok@go}{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}}
\@namedef{PY@tok@gt}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}}
\@namedef{PY@tok@err}{\def\PY@bc##1{{\setlength{\fboxsep}{-\fboxrule}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}}
\@namedef{PY@tok@kc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kd}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kr}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@bp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@fm}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@vc}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vg}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vi}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vm}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@sa}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sb}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sc}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@dl}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@s2}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sh}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@s1}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@mb}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mf}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mh}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mi}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@il}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mo}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@ch}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cm}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cpf}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@c1}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cs}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}

\def\PYZbs{\char`\\}
\def\PYZus{\char`\_}
\def\PYZob{\char`\{}
\def\PYZcb{\char`\}}
\def\PYZca{\char`\^}
\def\PYZam{\char`\&}
\def\PYZlt{\char`\<}
\def\PYZgt{\char`\>}
\def\PYZsh{\char`\#}
\def\PYZpc{\char`\%}
\def\PYZdl{\char`\$}
\def\PYZhy{\char`\-}
\def\PYZsq{\char`\'}
\def\PYZdq{\char`\"}
\def\PYZti{\char`\~}
% for compatibility with earlier versions
\def\PYZat{@}
\def\PYZlb{[}
\def\PYZrb{]}
\makeatother


    % For linebreaks inside Verbatim environment from package fancyvrb. 
    \makeatletter
        \newbox\Wrappedcontinuationbox 
        \newbox\Wrappedvisiblespacebox 
        \newcommand*\Wrappedvisiblespace {\textcolor{red}{\textvisiblespace}} 
        \newcommand*\Wrappedcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}} 
        \newcommand*\Wrappedcontinuationindent {3ex } 
        \newcommand*\Wrappedafterbreak {\kern\Wrappedcontinuationindent\copy\Wrappedcontinuationbox} 
        % Take advantage of the already applied Pygments mark-up to insert 
        % potential linebreaks for TeX processing. 
        %        {, <, #, %, $, ' and ": go to next line. 
        %        _, }, ^, &, >, - and ~: stay at end of broken line. 
        % Use of \textquotesingle for straight quote. 
        \newcommand*\Wrappedbreaksatspecials {% 
            \def\PYGZus{\discretionary{\char`\_}{\Wrappedafterbreak}{\char`\_}}% 
            \def\PYGZob{\discretionary{}{\Wrappedafterbreak\char`\{}{\char`\{}}% 
            \def\PYGZcb{\discretionary{\char`\}}{\Wrappedafterbreak}{\char`\}}}% 
            \def\PYGZca{\discretionary{\char`\^}{\Wrappedafterbreak}{\char`\^}}% 
            \def\PYGZam{\discretionary{\char`\&}{\Wrappedafterbreak}{\char`\&}}% 
            \def\PYGZlt{\discretionary{}{\Wrappedafterbreak\char`\<}{\char`\<}}% 
            \def\PYGZgt{\discretionary{\char`\>}{\Wrappedafterbreak}{\char`\>}}% 
            \def\PYGZsh{\discretionary{}{\Wrappedafterbreak\char`\#}{\char`\#}}% 
            \def\PYGZpc{\discretionary{}{\Wrappedafterbreak\char`\%}{\char`\%}}% 
            \def\PYGZdl{\discretionary{}{\Wrappedafterbreak\char`\$}{\char`\$}}% 
            \def\PYGZhy{\discretionary{\char`\-}{\Wrappedafterbreak}{\char`\-}}% 
            \def\PYGZsq{\discretionary{}{\Wrappedafterbreak\textquotesingle}{\textquotesingle}}% 
            \def\PYGZdq{\discretionary{}{\Wrappedafterbreak\char`\"}{\char`\"}}% 
            \def\PYGZti{\discretionary{\char`\~}{\Wrappedafterbreak}{\char`\~}}% 
        } 
        % Some characters . , ; ? ! / are not pygmentized. 
        % This macro makes them "active" and they will insert potential linebreaks 
        \newcommand*\Wrappedbreaksatpunct {% 
            \lccode`\~`\.\lowercase{\def~}{\discretionary{\hbox{\char`\.}}{\Wrappedafterbreak}{\hbox{\char`\.}}}% 
            \lccode`\~`\,\lowercase{\def~}{\discretionary{\hbox{\char`\,}}{\Wrappedafterbreak}{\hbox{\char`\,}}}% 
            \lccode`\~`\;\lowercase{\def~}{\discretionary{\hbox{\char`\;}}{\Wrappedafterbreak}{\hbox{\char`\;}}}% 
            \lccode`\~`\:\lowercase{\def~}{\discretionary{\hbox{\char`\:}}{\Wrappedafterbreak}{\hbox{\char`\:}}}% 
            \lccode`\~`\?\lowercase{\def~}{\discretionary{\hbox{\char`\?}}{\Wrappedafterbreak}{\hbox{\char`\?}}}% 
            \lccode`\~`\!\lowercase{\def~}{\discretionary{\hbox{\char`\!}}{\Wrappedafterbreak}{\hbox{\char`\!}}}% 
            \lccode`\~`\/\lowercase{\def~}{\discretionary{\hbox{\char`\/}}{\Wrappedafterbreak}{\hbox{\char`\/}}}% 
            \catcode`\.\active
            \catcode`\,\active 
            \catcode`\;\active
            \catcode`\:\active
            \catcode`\?\active
            \catcode`\!\active
            \catcode`\/\active 
            \lccode`\~`\~ 	
        }
    \makeatother

    \let\OriginalVerbatim=\Verbatim
    \makeatletter
    \renewcommand{\Verbatim}[1][1]{%
        %\parskip\z@skip
        \sbox\Wrappedcontinuationbox {\Wrappedcontinuationsymbol}%
        \sbox\Wrappedvisiblespacebox {\FV@SetupFont\Wrappedvisiblespace}%
        \def\FancyVerbFormatLine ##1{\hsize\linewidth
            \vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
                \doublehyphendemerits\z@\finalhyphendemerits\z@
                \strut ##1\strut}%
        }%
        % If the linebreak is at a space, the latter will be displayed as visible
        % space at end of first line, and a continuation symbol starts next line.
        % Stretch/shrink are however usually zero for typewriter font.
        \def\FV@Space {%
            \nobreak\hskip\z@ plus\fontdimen3\font minus\fontdimen4\font
            \discretionary{\copy\Wrappedvisiblespacebox}{\Wrappedafterbreak}
            {\kern\fontdimen2\font}%
        }%
        
        % Allow breaks at special characters using \PYG... macros.
        \Wrappedbreaksatspecials
        % Breaks at punctuation characters . , ; ? ! and / need catcode=\active 	
        \OriginalVerbatim[#1,codes*=\Wrappedbreaksatpunct]%
    }
    \makeatother

    % Exact colors from NB
    \definecolor{incolor}{HTML}{303F9F}
    \definecolor{outcolor}{HTML}{D84315}
    \definecolor{cellborder}{HTML}{CFCFCF}
    \definecolor{cellbackground}{HTML}{F7F7F7}
    
    % prompt
    \makeatletter
    \newcommand{\boxspacing}{\kern\kvtcb@left@rule\kern\kvtcb@boxsep}
    \makeatother
    \newcommand{\prompt}[4]{
        {\ttfamily\llap{{\color{#2}[#3]:\hspace{3pt}#4}}\vspace{-\baselineskip}}
    }
    

    
    % Prevent overflowing lines due to hard-to-break entities
    \sloppy 
    % Setup hyperref package
    \hypersetup{
      breaklinks=true,  % so long urls are correctly broken across lines
      colorlinks=true,
      urlcolor=urlcolor,
      linkcolor=linkcolor,
      citecolor=citecolor,
      }
    % Slightly bigger margins than the latex defaults
    
    \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
    
    

\begin{document}
    
    \maketitle
    
    

    
    \hypertarget{ux4e60ux9898-4.5}{%
\section{习题 4.5}\label{ux4e60ux9898-4.5}}

\begin{figure}
\centering
\includegraphics{https://tva1.sinaimg.cn/large/008i3skNly1gr9qnd43plj31a40hun3k.jpg}
\caption{习题 4.5}
\end{figure}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{1}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{data} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n+nf}{read.table}\PY{p}{(}\PY{l+s}{\PYZdq{}}\PY{l+s}{ex\PYZus{}4\PYZus{}5.utf8.txt\PYZdq{}}\PY{p}{,} \PY{n}{head}\PY{o}{=}\PY{k+kc}{TRUE}\PY{p}{)}\PY{p}{;} \PY{n}{data}
\end{Verbatim}
\end{tcolorbox}

    A data.frame: 30 × 8
\begin{tabular}{r|llllllll}
  & X1 & X2 & X3 & X4 & X5 & X6 & X7 & X8\\
  & <dbl> & <dbl> & <dbl> & <dbl> & <dbl> & <dbl> & <dbl> & <dbl>\\
\hline
	山西 &  8.35 & 23.53 &  7.51 &  8.62 & 17.42 & 10.00 & 1.04 & 11.21\\
	内蒙古 &  9.25 & 23.75 &  6.61 &  9.19 & 17.77 & 10.48 & 1.72 & 10.51\\
	吉林 &  8.19 & 30.50 &  4.72 &  9.78 & 16.28 &  7.60 & 2.52 & 10.32\\
	黑龙江 &  7.73 & 29.20 &  5.42 &  9.43 & 19.29 &  8.49 & 2.52 & 10.00\\
	河南 &  9.42 & 27.93 &  8.20 &  8.14 & 16.17 &  9.42 & 1.55 &  9.76\\
	甘肃 &  9.16 & 27.98 &  9.01 &  9.32 & 15.99 &  9.10 & 1.82 & 11.35\\
	青海 & 10.06 & 28.64 & 10.52 & 10.05 & 16.18 &  8.39 & 1.96 & 10.81\\
	河北 &  9.09 & 28.12 &  7.40 &  9.62 & 17.26 & 11.12 & 2.49 & 12.65\\
	陕西 &  9.41 & 28.20 &  5.77 & 10.80 & 16.36 & 11.56 & 1.53 & 12.17\\
	宁夏 &  8.70 & 28.12 &  7.21 & 10.53 & 19.45 & 13.30 & 1.66 & 11.96\\
	新疆 &  6.93 & 29.85 &  4.54 &  9.49 & 16.62 & 10.65 & 1.88 & 13.61\\
	湖北 &  8.67 & 36.05 &  7.31 &  7.75 & 16.67 & 11.68 & 2.38 & 12.88\\
	云南 &  9.98 & 37.69 &  7.01 &  8.94 & 16.15 & 11.08 & 0.83 & 11.67\\
	湖南 &  6.77 & 38.69 &  6.01 &  8.82 & 14.79 & 11.44 & 1.74 & 13.23\\
	安徽 &  8.14 & 37.75 &  9.61 &  8.49 & 13.15 &  9.76 & 1.28 & 11.28\\
	贵州 &  7.67 & 35.71 &  8.04 &  8.31 & 15.13 &  7.76 & 1.41 & 13.25\\
	辽宁 &  7.90 & 39.77 &  8.49 & 12.94 & 19.27 & 11.05 & 2.04 & 13.29\\
	四川 &  7.18 & 40.91 &  7.32 &  8.94 & 17.60 & 12.75 & 1.14 & 14.80\\
	山东 &  8.82 & 33.70 &  7.59 & 10.98 & 18.82 & 14.73 & 1.78 & 10.10\\
	江西 &  6.25 & 35.02 &  4.72 &  6.28 & 10.03 &  7.15 & 1.93 & 10.39\\
	福建 & 10.60 & 52.41 &  7.70 &  9.98 & 12.53 & 11.70 & 2.31 & 14.69\\
	广西 &  7.27 & 52.65 &  3.84 &  9.16 & 13.03 & 15.26 & 1.98 & 14.57\\
	海南 & 13.45 & 55.85 &  5.50 &  7.45 &  9.55 &  9.52 & 2.21 & 16.30\\
	天津 & 10.85 & 44.68 &  7.32 & 14.51 & 17.13 & 12.08 & 1.26 & 11.57\\
	江苏 &  7.21 & 45.79 &  7.66 & 10.36 & 16.56 & 12.86 & 2.25 & 11.69\\
	浙江 &  7.68 & 50.37 & 11.35 & 13.30 & 19.25 & 14.59 & 2.75 & 14.87\\
	北京 &  7.78 & 48.44 &  8.00 & 20.51 & 22.12 & 15.73 & 1.15 & 16.61\\
	西藏 &  7.94 & 39.65 & 20.97 & 20.82 & 22.52 & 12.41 & 1.75 &  7.90\\
	上海 &  8.28 & 64.34 &  8.00 & 22.22 & 20.06 & 15.12 & 0.72 & 22.89\\
	广东 & 12.47 & 76.39 &  5.52 & 11.24 & 14.52 & 22.00 & 5.46 & 25.50\\
\end{tabular}


    
    \hypertarget{section}{%
\subsection{(1)}\label{section}}

    在第一章中做过，用 cor 获取相关系数：

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{2}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{R} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n+nf}{cor}\PY{p}{(}\PY{n}{data}\PY{p}{)}\PY{p}{;} \PY{n}{R}
\end{Verbatim}
\end{tcolorbox}

    A matrix: 8 × 8 of type dbl
\begin{tabular}{r|llllllll}
  & X1 & X2 & X3 & X4 & X5 & X6 & X7 & X8\\
\hline
	X1 &  1.00000000 &  0.33364671 & -0.05453868 & -0.06125369 & -0.28936059 & 0.19879627 &  0.3486985 &  0.31867736\\
	X2 &  0.33364671 &  1.00000000 & -0.02290183 &  0.39893102 & -0.15630387 & 0.71113407 &  0.4135946 &  0.83495175\\
	X3 & -0.05453868 & -0.02290183 &  1.00000000 &  0.53332919 &  0.49676279 & 0.03282961 & -0.1390858 & -0.25835810\\
	X4 & -0.06125369 &  0.39893102 &  0.53332919 &  1.00000000 &  0.69842442 & 0.46791730 & -0.1712742 &  0.31275728\\
	X5 & -0.28936059 & -0.15630387 &  0.49676279 &  0.69842442 &  1.00000000 & 0.28012915 & -0.2082774 & -0.08123414\\
	X6 &  0.19879627 &  0.71113407 &  0.03282961 &  0.46791730 &  0.28012915 & 1.00000000 &  0.4168213 &  0.70158588\\
	X7 &  0.34869847 &  0.41359462 & -0.13908580 & -0.17127417 & -0.20827738 & 0.41682128 &  1.0000000 &  0.39886792\\
	X8 &  0.31867736 &  0.83495175 & -0.25835810 &  0.31275728 & -0.08123414 & 0.70158588 &  0.3988679 &  1.00000000\\
\end{tabular}


    
    \hypertarget{section}{%
\subsection{(2)}\label{section}}

    R 中用 \texttt{princomp} 来做 PCA，里面有个 \texttt{cor}
参数指定是否使用相关系数：

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{3}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{pca} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n+nf}{princomp}\PY{p}{(}\PY{n}{data}\PY{p}{,} \PY{n}{cor}\PY{o}{=}\PY{k+kc}{TRUE}\PY{p}{)}
\PY{n+nf}{summary}\PY{p}{(}\PY{n}{pca}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    
    \begin{Verbatim}[commandchars=\\\{\}]
Importance of components:
                         Comp.1    Comp.2    Comp.3     Comp.4     Comp.5
Standard deviation     1.759627 1.5385783 0.9591597 0.84019364 0.70600448
Proportion of Variance 0.387036 0.2959029 0.1149984 0.08824067 0.06230529
Cumulative Proportion  0.387036 0.6829389 0.7979373 0.88617801 0.94848330
                           Comp.6     Comp.7      Comp.8
Standard deviation     0.47946669 0.36162932 0.226868982
Proportion of Variance 0.02873604 0.01634697 0.006433692
Cumulative Proportion  0.97721934 0.99356631 1.000000000
    \end{Verbatim}

    
    这里从 \texttt{summary} 输出中就有各主成分的贡献率
\texttt{Proportion\ of\ Variance}， 以及累积贡献率
\texttt{Cumulative\ Proportion}。

其中前两个主成分的累积贡献率为 \(0.6829389\)。

    这里可以作图来对 PCA 结果有更直观的感受：

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{4}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n+nf}{plot}\PY{p}{(}\PY{n}{pca}\PY{p}{,} \PY{n}{type}\PY{o}{=}\PY{l+s}{\PYZdq{}}\PY{l+s}{lines\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{ex_4_5_files/ex_4_5_10_0.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    可以看到前两个主成分所占方差较大，所以只用前两个主成分就可以比较好的描述数据特征了。

    \hypertarget{section}{%
\subsection{(3)}\label{section}}

    从 \texttt{pca\$loading} 可以获取到个主成分的构成：

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{5}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{pca}\PY{o}{\PYZdl{}}\PY{n}{loadings}
\end{Verbatim}
\end{tcolorbox}

    
    \begin{Verbatim}[commandchars=\\\{\}]

Loadings:
   Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8
X1  0.250  0.241  0.694  0.377  0.502                     
X2  0.519                0.225 -0.424         0.282  0.643
X3        -0.475  0.578        -0.510  0.173 -0.381       
X4  0.254 -0.538         0.231        -0.399  0.472 -0.458
X5        -0.575        -0.285  0.516 -0.146 -0.159  0.521
X6  0.493 -0.135 -0.145 -0.224  0.177  0.755        -0.244
X7  0.317  0.261  0.286 -0.768        -0.355  0.131       
X8  0.509        -0.271  0.177        -0.305 -0.708 -0.181

               Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8
SS loadings     1.000  1.000  1.000  1.000  1.000  1.000  1.000  1.000
Proportion Var  0.125  0.125  0.125  0.125  0.125  0.125  0.125  0.125
Cumulative Var  0.125  0.250  0.375  0.500  0.625  0.750  0.875  1.000
    \end{Verbatim}

    
    取出前两个主成分：

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{6}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{pca}\PY{o}{\PYZdl{}}\PY{n}{loadings}\PY{p}{[}\PY{p}{,}\PY{l+m}{1}\PY{o}{:}\PY{l+m}{2}\PY{p}{]}
\end{Verbatim}
\end{tcolorbox}

    A matrix: 8 × 2 of type dbl
\begin{tabular}{r|ll}
  & Comp.1 & Comp.2\\
\hline
	X1 &  0.24960670 &  0.24123818\\
	X2 &  0.51923425 &  0.03760741\\
	X3 & -0.01848008 & -0.47543851\\
	X4 &  0.25409160 & -0.53808076\\
	X5 &  0.02169482 & -0.57544866\\
	X6 &  0.49266309 & -0.13467554\\
	X7 &  0.31714669 &  0.26068239\\
	X8 &  0.50933155 &  0.08708140\\
\end{tabular}


    
    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{7}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n+nf}{cat}\PY{p}{(}\PY{l+s}{\PYZdq{}}\PY{l+s}{Y\PYZus{}1 = \PYZdq{}}\PY{p}{,} \PY{n+nf}{paste}\PY{p}{(}\PY{n+nf}{round}\PY{p}{(}\PY{n}{pca}\PY{o}{\PYZdl{}}\PY{n}{loadings}\PY{p}{[}\PY{p}{,}\PY{l+m}{1}\PY{p}{]}\PY{p}{,} \PY{l+m}{3}\PY{p}{)}\PY{p}{,} \PY{l+s}{\PYZdq{}}\PY{l+s}{x\PYZus{}\PYZdq{}}\PY{p}{,} \PY{l+m}{1}\PY{o}{:}\PY{l+m}{8}\PY{p}{,} \PY{l+s}{\PYZdq{}}\PY{l+s}{+\PYZdq{}}\PY{p}{,} \PY{n}{sep}\PY{o}{=}\PY{l+s}{\PYZdq{}}\PY{l+s}{\PYZdq{}}\PY{p}{)}\PY{p}{,} \PY{l+s}{\PYZdq{}}\PY{l+s}{\PYZbs{}n\PYZdq{}}\PY{p}{)}
\PY{n+nf}{cat}\PY{p}{(}\PY{l+s}{\PYZdq{}}\PY{l+s}{Y\PYZus{}2 = \PYZdq{}}\PY{p}{,} \PY{n+nf}{paste}\PY{p}{(}\PY{n+nf}{round}\PY{p}{(}\PY{n}{pca}\PY{o}{\PYZdl{}}\PY{n}{loadings}\PY{p}{[}\PY{p}{,}\PY{l+m}{2}\PY{p}{]}\PY{p}{,} \PY{l+m}{3}\PY{p}{)}\PY{p}{,} \PY{l+s}{\PYZdq{}}\PY{l+s}{x\PYZus{}\PYZdq{}}\PY{p}{,} \PY{l+m}{1}\PY{o}{:}\PY{l+m}{8}\PY{p}{,} \PY{l+s}{\PYZdq{}}\PY{l+s}{+\PYZdq{}}\PY{p}{,} \PY{n}{sep}\PY{o}{=}\PY{l+s}{\PYZdq{}}\PY{l+s}{\PYZdq{}}\PY{p}{)}\PY{p}{,} \PY{l+s}{\PYZdq{}}\PY{l+s}{\PYZbs{}n\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Y\_1 =  0.25x\_1+ 0.519x\_2+ -0.018x\_3+ 0.254x\_4+ 0.022x\_5+ 0.493x\_6+ 0.317x\_7+
0.509x\_8+
Y\_2 =  0.241x\_1+ 0.038x\_2+ -0.475x\_3+ -0.538x\_4+ -0.575x\_5+ -0.135x\_6+ 0.261x\_7+
0.087x\_8+
    \end{Verbatim}

    即得到：

\[
\begin{aligned}
Y_1 &=  0.25x_1+ 0.519x_2 -0.018x_3+ 0.254x_4+ 0.022x_5+ 0.493x_6+ 0.317x_7+ 0.509x_8\\
Y_2 &=  0.241x_1+ 0.038x_2 -0.475x_3 -0.538x_4 -0.575x_5 -0.135x_6+ 0.261x_7+ 0.087x_8
\end{aligned}
\]

    \begin{itemize}
\tightlist
\item
  \(Y_1\)
  反映了各省人均消费水平，除烟茶酒（\(X_3\)）外，其他支出越高，其人均总体消费水平越高，而烟茶酒对其消费水平评价成负相关。
\item
  在 \$Y\_2
  \$中人烟酒、其他副食、衣着、日用品系数为负；粮食、副食、燃料、非商品系数为正，说明
  \(Y_2\) 的绝对值越大，各省人均消费的在生活必需品与高档品差异越大。
\end{itemize}

    \texttt{pca\$scores} 可以获取在个主成分下数据的得分：

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{8}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{pca}\PY{o}{\PYZdl{}}\PY{n}{scores}
\end{Verbatim}
\end{tcolorbox}

    A matrix: 30 × 8 of type dbl
\begin{tabular}{r|llllllll}
  & Comp.1 & Comp.2 & Comp.3 & Comp.4 & Comp.5 & Comp.6 & Comp.7 & Comp.8\\
\hline
	山西 & -1.71328041 & -0.1702972 & -0.16533704 &  0.23590437 &  0.569936490 &  0.29875410 & -0.48611208 & -0.09116991\\
	内蒙古 & -1.27970296 &  0.1344973 &  0.30689790 & -0.23043192 &  1.012468747 &  0.07198599 & -0.03717535 & -0.12143528\\
	吉林 & -1.31581695 &  0.8750360 & -0.11140786 & -0.68616712 &  0.247083948 & -1.08443042 &  0.57207381 &  0.05978027\\
	黑龙江 & -1.34833462 &  0.1041418 & -0.23606441 & -1.22149653 &  0.603997992 & -0.91121622 &  0.32415606 &  0.48423086\\
	河南 & -1.51135274 &  0.3575657 &  0.74485489 &  0.15916151 &  0.318199302 &  0.22362082 & -0.08877150 &  0.06122241\\
	甘肃 & -1.20243857 &  0.1962559 &  0.77061864 &  0.03290876 &  0.031513421 & -0.17668219 & -0.32211193 & -0.21328633\\
	青海 & -1.13238706 &  0.0184613 &  1.56666527 &  0.16585236 &  0.010877250 & -0.35640196 & -0.28908048 & -0.16241711\\
	河北 & -0.39890334 &  0.3006773 &  0.44000732 & -0.76975727 &  0.557414414 & -0.25219732 & -0.24503792 & -0.29330670\\
	陕西 & -0.62321145 &  0.2873967 & -0.03974784 &  0.30778811 &  0.905168787 &  0.13749943 &  0.12213088 & -0.46191904\\
	宁夏 & -0.43775323 & -0.6567395 & -0.14502865 & -0.45256266 &  1.065800286 &  0.48700867 & -0.17027760 & -0.07691451\\
	新疆 & -0.83249622 &  0.4284772 & -1.31216366 & -0.52353448 &  0.233313443 & -0.33824264 & -0.17043019 & -0.25789460\\
	湖北 & -0.17335839 &  0.5996948 &  0.13105793 & -0.70785427 &  0.102796108 &  0.12846023 & -0.30601657 &  0.18738388\\
	云南 & -0.67809647 &  0.3005293 &  0.22841114 &  1.16558732 &  0.547410479 &  0.63752652 & -0.04440406 &  0.35660242\\
	湖南 & -0.52687091 &  0.5617115 & -1.17427177 & -0.22730234 & -0.637516046 &  0.19411512 & -0.06581257 & -0.09598281\\
	安徽 & -1.13401837 &  0.4479633 &  0.22310249 &  0.63162229 & -1.135121996 &  0.47275352 & -0.19762601 & -0.13391580\\
	贵州 & -1.28087147 &  0.4355961 & -0.31186180 &  0.42406853 & -0.717322171 & -0.42721526 & -0.60824015 &  0.19301087\\
	辽宁 &  0.04597426 & -0.9973278 & -0.18880188 & -0.39435146 &  0.001524098 & -0.53145394 & -0.04009504 &  0.24617664\\
	四川 & -0.13719329 & -0.3495031 & -1.18966949 &  0.16211927 & -0.161510999 &  0.57244188 & -0.67692322 &  0.37080157\\
	山东 & -0.14352770 & -0.6936321 &  0.06841930 & -0.54597236 &  0.794096721 &  0.96009874 &  0.42746893 &  0.01292320\\
	江西 & -1.99443644 &  2.1443095 & -1.04918408 & -0.09124788 & -1.589855377 & -0.30165950 &  0.42014491 & -0.34738661\\
	福建 &  1.17362616 &  1.3976957 &  0.84741141 &  0.73423571 & -0.617905779 &  0.02473358 &  0.19700508 &  0.01148641\\
	广西 &  1.07457604 &  1.2563578 & -1.63199669 & -0.07653990 & -0.693330619 &  0.86788824 &  0.55704451 & -0.06662925\\
	海南 &  1.42511451 &  3.2327307 &  1.66191693 &  1.96723103 & -0.096122739 & -0.30013866 &  0.07821521 &  0.19333947\\
	天津 &  0.44287310 & -0.4821918 &  0.68627477 &  1.26444816 &  0.725655997 &  0.11261393 &  0.84478504 &  0.12783423\\
	江苏 &  0.15591226 & -0.1151304 & -0.52099459 & -0.73836503 & -0.693942745 &  0.31633353 &  0.41504815 &  0.29813456\\
	浙江 &  1.54097092 & -1.3970121 &  0.15434604 & -1.09621902 & -0.781850716 &  0.04654020 & -0.22375699 &  0.25892031\\
	北京 &  1.82277984 & -2.9374614 & -1.25748825 &  0.55406973 &  0.661967309 & -0.22210262 &  0.33005139 & -0.14855873\\
	西藏 & -0.13551813 & -4.9923526 &  2.37698478 & -0.46230359 & -1.441186117 &  0.12998035 &  0.22358976 & -0.14715544\\
	上海 &  3.30394931 & -2.6047252 & -1.70041148 &  2.01766545 & -0.031636936 & -0.79913006 & -0.29367453 & -0.08851021\\
	广东 &  7.01379233 &  2.3172751 &  0.82746069 & -1.59855678 &  0.208077446 &  0.01851593 & -0.24616755 & -0.15536476\\
\end{tabular}


    
    从中我们获取的一主成分的得分，并进行排序：

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{9}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{Comp.1.scores} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n}{pca}\PY{o}{\PYZdl{}}\PY{n}{scores}\PY{p}{[}\PY{p}{,}\PY{l+m}{1}\PY{p}{]}
\PY{n}{Comp.1.scores.sorted} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n}{Comp.1.scores}\PY{p}{[}\PY{n+nf}{order}\PY{p}{(}\PY{n}{Comp.1.scores}\PY{p}{,} \PY{n}{decreasing} \PY{o}{=} \PY{k+kc}{TRUE}\PY{p}{)}\PY{p}{]}
\end{Verbatim}
\end{tcolorbox}

    为了好看，稍微处理一下结果再输出：

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{10}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{idx} \PY{o}{\PYZlt{}\PYZhy{}} \PY{l+m}{1}\PY{o}{:}\PY{n+nf}{length}\PY{p}{(}\PY{n}{Comp.1.scores.sorted}\PY{p}{)}
\PY{n+nf}{cbind}\PY{p}{(}\PY{n}{idx}\PY{p}{,} \PY{n+nf}{data.frame}\PY{p}{(}\PY{n}{Comp.1.scores.sorted}\PY{p}{)}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    A data.frame: 30 × 2
\begin{tabular}{r|ll}
  & idx & Comp.1.scores.sorted\\
  & <int> & <dbl>\\
\hline
	广东 &  1 &  7.01379233\\
	上海 &  2 &  3.30394931\\
	北京 &  3 &  1.82277984\\
	浙江 &  4 &  1.54097092\\
	海南 &  5 &  1.42511451\\
	福建 &  6 &  1.17362616\\
	广西 &  7 &  1.07457604\\
	天津 &  8 &  0.44287310\\
	江苏 &  9 &  0.15591226\\
	辽宁 & 10 &  0.04597426\\
	西藏 & 11 & -0.13551813\\
	四川 & 12 & -0.13719329\\
	山东 & 13 & -0.14352770\\
	湖北 & 14 & -0.17335839\\
	河北 & 15 & -0.39890334\\
	宁夏 & 16 & -0.43775323\\
	湖南 & 17 & -0.52687091\\
	陕西 & 18 & -0.62321145\\
	云南 & 19 & -0.67809647\\
	新疆 & 20 & -0.83249622\\
	青海 & 21 & -1.13238706\\
	安徽 & 22 & -1.13401837\\
	甘肃 & 23 & -1.20243857\\
	内蒙古 & 24 & -1.27970296\\
	贵州 & 25 & -1.28087147\\
	吉林 & 26 & -1.31581695\\
	黑龙江 & 27 & -1.34833462\\
	河南 & 28 & -1.51135274\\
	山西 & 29 & -1.71328041\\
	江西 & 30 & -1.99443644\\
\end{tabular}


    

    % Add a bibliography block to the postdoc
    
    
    
\end{document}
